﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SimpleScrum.Helpers
{
    public static class HtmlHelpers
    {
        public static string Truncate(this HtmlHelper helper, string input, int length)
        {
            if (input.Length <= length)
            {
                return input;
            }
            else
            {
                return input.Substring(0, length) + "...";
            }
        }
        public static MvcHtmlString MyButton(this HtmlHelper htmlHelper, string id, string text)
        {
            var button = new TagBuilder("input");
            button.MergeAttribute("type", "button");
            button.MergeAttribute("value", text);
            // get the id from the current route:
            var routeId = htmlHelper.ViewContext.RouteData.Values["id"] as string;
            if (id == routeId)
            {
                button.MergeAttribute("class", "active");
            }
            return MvcHtmlString.Create(button.ToString(TagRenderMode.SelfClosing));
        }
    }
}